<script lang="tsx">
import {Component, Vue, Model} from 'vue-property-decorator'
import Child from "./Child.vue"

const symbol = Symbol('baz')


interface Props {
    checked: string;
}

@Component
export default class App extends Vue {



    // 这种可以局部变量也可以字段上，可以渲染到页面。 但是都ts会提示语法错误，但是执行没问题 <this.App2/>
    App2 = {
        render() {
            return (<div>Vue 3.0</div>);
        }
    };

    // 这种只能用局部变量可以渲染到页面,放到字段上，会提示找不到渲染函数
    App1 = () => <div>Vue 3.0</div>;

    render() {
        // vue3 Fragment
        /*const App = () => (
            <>
                <span>I'm</span>
                <span>Fragment</span>
            </>
        );*/

        // 带变量的渲染
        const placeholderText = "email";
        const App = () => <input type="email" placeholder={placeholderText}/>;


        // 这样相当于那个vue组件类
        /*const vShow = {
            data() {
                return { visible: false };
            },
            render() {
                return <input v-show={this.visible} />;
            },
        };*/

        // 函数式组件
        const ABC11 = (prop: any, context: any) => {
            console.log(prop)
            console.log(context)
            return (
                <h2>你好</h2>
            )
        }
        return (
            <div>
                <App/>
                <hr/>
                <input type="text" v-model={this.val}/>
                <hr/>
                <ABC11 props={{key: "foo"}}></ABC11>

                {/*给子组件传递值这种*/}
                <Child props={{
                    checked: false,
                    "vOn:change": () => {
                        console.log('dfdf')
                    }
                }}/>
                {/*两种方式都可以*/}
                <Child {...{
                    checked: false,
                    "vOn:change": () => {
                        console.log('dfdf')
                    }
                }}/>
            </div>
        )
    }

    val!: string
}
</script>

<style scoped>
#app {
    font-family: Avenir, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
    margin-top: 60px;
}
</style>
